package com.app.utils;

import java.util.ResourceBundle;

import org.apache.log4j.Logger;

/**
 * 加载资源文件工具类
 */
public class Config {
	static Logger logger = Logger.getLogger(Config.class.getName());

	/**
	 * 
	 * @param resourceName
	 *            资源文件
	 * @param key
	 *            属性名称
	 * @return
	 */
	public static String getAttribute(String resourceName, String key) {
		String value = null;
		try {
			ResourceBundle resource = ResourceBundle.getBundle(resourceName);
			logger.info("加载" + resourceName + ".properties资源文件的[" + key + "]属性值");
			value = resource.getString(key);
		} catch (RuntimeException e) {
			logger.warn("资源文件" + resourceName + ".properties没有[" + key + "]属性");
		}
		return value;
	}
}
